package cn.qfei.qiyuesuo.service.impl;

import cn.qfei.qiyuesuo.bo.*;
import cn.qfei.qiyuesuo.common.ContractConstant;
import cn.qfei.qiyuesuo.common.enums.ErrorCode;
import cn.qfei.qiyuesuo.service.FeishuNoticeService;
import cn.qfei.qiyuesuo.service.HankouDataService;
import cn.qfei.qiyuesuo.service.KaixuanSignService;
import cn.qfei.qiyuesuo.service.QiyuesuoApiService;
import cn.qfei.qiyuesuo.vo.HankouDataSendVo;
import cn.qfei.qiyuesuo.vo.qiyuesuo.QysContractNoticeVo;
import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
@Slf4j
public class HankouDataServiceImpl implements HankouDataService {
//    @Autowired
//    private FeishuNoticeService feishuNoticeService;
    @Autowired
    private QiyuesuoApiService qiyuesuoApiService;


    private boolean isNodeNameMatch(String preSealSatus, List<TaskInstanceBo> taskInstanceList) {
        if (taskInstanceList==null||taskInstanceList.size()==0){
            return false;
        }
        for (TaskInstanceBo taskInstanceBo: taskInstanceList ) {
            if (taskInstanceBo==null){
                continue;
            }
            if (preSealSatus.equals(taskInstanceBo.getTaskInstanceName())){
                return true;
            }
        }
        return false;
    }





    private List<TaskBo> getNeedTaskNode(List<TaskBo> taskLis,String fsContractName) {
        List<TaskBo> reList=new ArrayList<>();
        if (taskLis==null||taskLis.size()==0){
            return null;
        }

        for (TaskBo taskBo: taskLis) {
            if (taskBo==null){
                continue;
            }
            if (!("PENDING".equals(taskBo.getStatus())||"TRANSFERRED".equals(taskBo.getStatus()))){
                log.info("任务状态{},跳过",taskBo.getStatus());
            }
            if (!fsContractName.equals(taskBo.getNodeName())){
                log.info("节点名不对{},跳过",taskBo.getNodeName());

            }

            reList.add(taskBo);

        }
        return reList;
    }
}
